package guowei.guliproduct.product.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import java.io.Serializable;

import guowei.common.group.AddGroup;
import guowei.common.group.StatusShow;
import guowei.common.group.UpdateGroup;
import guowei.common.group.UpdateStatusGroup;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import javax.validation.constraints.*;

/**
 * 品牌  利用 JSR303功能实现后端校验   利用validator依赖
 * 	@NotNull(groups = {UpdateGroup.class},message = "自定义的报错信息")
 * 				分组校验  UpdateGroup接口 (表示controller里用@Validated({UpdateGroup.class})标注的方法才会生效)
 *
 * @author guoguo
 * @email 1573746397@qq.com
 * @date 2023-05-21 17:38:07
 */
@Data
@TableName("pms_brand")
public class BrandEntity implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 * 品牌id
	 */
	@NotNull(groups = {UpdateGroup.class},message = "修改品牌时brandId必须带上")
	@Null(groups = {AddGroup.class},message = "添加品牌时brandId必须为空")
	@TableId
	private Long brandId;
	/**
	 * 品牌名
	 */
	@NotEmpty(message = "name名不能为空",groups = {AddGroup.class, UpdateGroup.class})
	private String name;
	/**
	 * 品牌logo地址
	 */
	@NotNull(groups = {AddGroup.class, UpdateGroup.class})
	@URL(message = "logo地址必须是正确的地址",groups = {AddGroup.class, UpdateGroup.class})
	private String logo;
	/**
	 * 介绍
	 */
	private String descript;
	/**
	 * 显示状态[0-不显示；1-显示]		利用自定义校验器
	 */
	@StatusShow(vals={0,1},message = "显示状态必须为1或0",groups = {AddGroup.class, UpdateStatusGroup.class})
	private Integer showStatus;
	/**
	 * 检索首字母
	 */
	@Pattern(regexp = "^[a-zA-Z]$",message = "检索首字母必须是一个字母",groups = {AddGroup.class, UpdateGroup.class})
	private String firstLetter;
	/**
	 * 排序
	 */
	@Min(value = 0,message = "排序字段必须是大于等于0的数字",groups = {AddGroup.class, UpdateGroup.class})
	private Integer sort;

}
